Merge branch 'dev-docs' of https://github.com/CraigJPerry/cleanflight into CraigJPerr...
[betaflight.git] / docs / development / Building in Eclipse.md
blob06c55fb91d6f5b4ec1142bdd8f7d00d4b96616d2
1 # Building in Eclipse
3 How to build, test & debug Cleanflight in Eclipse on Linux, Windows & MacOS.
5 ## Checklist
7 Use this checklist to make sure you didn't miss a step. Versions mandated below are current and correct as of January 2016.
9 - [ ] [Download and Install](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) the latest (currently 1.8) 64bit Oracle JDK [read more](#install-the-jdk)
10 - [ ] [Download and Install](https://eclipse.org/downloads/packages/eclipse-ide-cc-developers/lunasr2) Eclipse Luna (4.4) 64bit CDT edition, **NB:** not Mars or Neon [read more](#install-eclipse)
11 - [ ] [Download and Install](https://launchpad.net/gcc-arm-embedded/4.9/4.9-2015-q3-update) the GCC ARM Embedded toolchain 4.9-2015-q3-update [read more](#install-arm-toolchain)
12  - [ ] *Windows platform only:* [Download and Install](https://github.com/gnuarmeclipse/windows-build-tools/releases) the latest GNU ARM Eclipse Windows Build Tools
13  - [ ] *Windows platform only:* Download and Install either [Cygwin](http://cygwin.com/install.html) or [MinGW MSYS](http://sourceforge.net/projects/mingw/files/latest/download)
14 - [ ] Optionally [Download and Install](https://github.com/gnuarmeclipse/openocd/releases) the latest GNU ARM Eclipse OpenOCD [read more](#install-openocd)
15  - [ ] *Linux platform only:* [Configure UDEV](http://gnuarmeclipse.github.io/openocd/install/#udev) to recognise USB JTAG probes
16  - [ ] *Windows platform only:* [Download and Install](http://www.st.com/web/en/catalog/tools/FM147/SC1887/PF260219) the ST-Link / ST-LinkV2 drivers. These drivers do work on Windows 10 even if not yet mentioned by ST.
17 - [ ] Optionally [Download and Install](https://github.com/gnuarmeclipse/qemu/releases) the latest GNU ARM Eclipse QEMU [read more](#install-qemu)
18 - [ ] Add a new update site to Eclipse named "GNU ARM Eclipse Plugins" with the URL "http://gnuarmeclipse.sourceforge.net/updates" and install all the features offered
19 - [ ] Configure [the recommended workspace settings](http://gnuarmeclipse.github.io/eclipse/workspace/preferences/)
20 - [ ] Checkout the cleanflight source code [read more](#checkout-cleanflight)
21  - [ ] *Windows platform only:* Add the msys or cygwin bin directory to the project path
22 - [ ] Build the code by going to *Project menu -> Build All* [read more](#build)
23 - [ ] Run the tests by creating and running a make target named "test"
24 - [ ] Configure debugging [read more](#configure-debugging)
26 ## Extended Notes
28 ### Install the JDK
30 The [minimum JDK version](http://gnuarmeclipse.github.io/plugins/install/#java) supported by GNU Arm Eclipse is 1.7 but the current latest, 1.8, is recommended instead. While Oracle JDK is the recommended version, [they do also support](http://gnuarmeclipse.github.io/plugins/install/#java) the OpenJDK.
32 ### Install Eclipse
34 Eclipse Luna v4.4 is the preferred version for GNU Arm Tools currently. The minimum Eclipse version is Kepler 4.3. The maximum is Mars 4.5 although it is not tested by GNU Arm Eclipse and some things are [known to be broken](http://gnuarmeclipse.github.io/plugins/install/#eclipse--cdt). Eclipse Neon is currently not released.
36 CDT v8.6.0, as shipped in the Eclipse Luna CDT download, is recommended. The minimum CDT version is 8.3.
38 The 64bit Eclipse is preferred but a 32bit Eclipse can be used; ensure you run it on a 32bit JDK.
40 ### Install ARM Toolchain
42 The minimum version is 4.8-2014-q2. The maximum, and currently recommended version, is 4_9-2015q3.
44 GNU ARM Tools recommends that you don't add the toolchain to your path environment variable. This means you can install multiple versions of the toolchain without conflict. If you'll install only one version, it can make life easier when working outside Eclipse to add it to your path.
46 Retain the default installation directories so that the GNU ARM Plugins can locate the toolchain.
48 ### Install OpenOCD
50 You should install OpenOCD If you will be debugging on real hardware, such as the STM32F3DISCOVERY dev board. It is not required to simply build Cleanflight or run the tests.
52 ### Install QEMU
54 No tests currently run on the QEMU emulator therefore this install is entirely optional. It is useful to test your installation, since you can compile and run a blinky demo.
56 ### Checkout Cleanflight
58 If you'll be submitting changes to cleanflight, [fork the repository](https://help.github.com/articles/fork-a-repo/) on GitHub and checkout your copy.
60 In Eclipse go to *File -> Import* choose *Git -> Projects from Git*
62 ![projects from git](assets/building-in-eclipse/checkout-cleanflight-001.PNG)
64 Choose *Clone URI*
66 ![clone uri](assets/building-in-eclipse/checkout-cleanflight-002.PNG)
68 Enter the URI https://github.com/cleanflight/cleanflight or if you've forked the repo, enter your URI instead. With a fork, you will need to specify your authentication details
70 ![enter uri](assets/building-in-eclipse/checkout-cleanflight-003.PNG)
72 On the branch selection dialog, de-select all branches and select only *master*
74 ![choose branches to clone](assets/building-in-eclipse/checkout-cleanflight-004.PNG)
76 Select the default destination directory
78 ![destination](assets/building-in-eclipse/checkout-cleanflight-005.PNG)
80 When the download completes, choose *Use the New Project wizard* and click Finish
82 ![finish](assets/building-in-eclipse/checkout-cleanflight-006.PNG)
84 Choose *C/C++ -> Makefile Project with Existing Code*
86 ![makefile project](assets/building-in-eclipse/checkout-cleanflight-007.PNG)
88 Enter cleanflight as the project name and browse to your home directory -> git -> cleanflight for the existing code location. Ensure the C (cleanflight) and C++ (tests) languages are checked. Choose the Cross ARM GCC toolchain for the Indexer Settings. Click finish.
90 ![finish checkout](assets/building-in-eclipse/checkout-cleanflight-008.PNG)
92 Set your build and debug targets by going to project properties -> C/C++ Build and choose the Behaviour tab. Replace "all" in the build box with "TARGET=xxx DEBUG=GDB" where xxx is your platform such as NAZE
94 ![build](assets/building-in-eclipse/checkout-cleanflight-012.PNG)
96 On Windows only, add msys or cygwin bin directory to the project's path by right clicking the project and choosing properties
98 ![properties](assets/building-in-eclipse/checkout-cleanflight-009.PNG)
100 Edit the path variable in *C/C++ Build -> Environment*
102 ![edit path](assets/building-in-eclipse/checkout-cleanflight-010.PNG)
104 Append the full path to the relevant bin dir
106 ![append bin dir](assets/building-in-eclipse/checkout-cleanflight-011.PNG)
108 ### Build
110 Choose project -> build all
112 ![build all](assets/building-in-eclipse/checkout-cleanflight-013.PNG)
114 ### Configure Debugging
116 Choose debug -> debug configurations
118 ![debug configurations](assets/building-in-eclipse/checkout-cleanflight-014.PNG)
120 Create a new OpenOCD configuration for the obj\main\cleanflight_XXX.elf application (this file is generated by the build step above)
122 ![debug configurations](assets/building-in-eclipse/checkout-cleanflight-015.PNG)
124 Add the appropriate openocd board configuration parameter for your dev platform
126 ![openocd target](assets/building-in-eclipse/checkout-cleanflight-016.PNG)
128 Add the target to your debug menu favourites
130 ![debug favs](assets/building-in-eclipse/checkout-cleanflight-017.PNG)